#!/bin/bash
# -*- mode: shell; coding: utf-8 -*-

GCU_LOC=http://support.googlecode.com/svn/trunk/scripts/googlecode_upload.py

FILE=$(ls *.deb | head -n 1)
VERSION=$(echo $FILE | cut -d '_' -f 2)
SUMMARY="Hanzi Trainer, v$VERSION (Debian package)"

if [ ! -f googlecode_upload.py ]; then
    wget -q $GCU_LOC
fi

# Upload package
python googlecode_upload.py -s "$SUMMARY" -p hanzitrainer $FILE -l Type-Package,Featured,OpSys-Linux

# Create Packages.gz for trivial repository
mkdir -p files
cp $FILE files
dpkg-scanpackages -m files /dev/null > Packages
gzip Packages

python googlecode_upload.py -s "List of packages" -p hanzitrainer Packages.gz

# clean
rm Packages.gz -f
rm files/ -rf
